<?php
/**
 * River item class.
 *
 * @package    Elgg.Core
 * @subpackage Core
 * 
 * @property int    $id            The unique identifier (read-only)
 * @property int    $subject_guid  The GUID of the actor
 * @property int    $object_guid   The GUID of the object
 * @property int    $annotation_id The ID of the annotation involved in the action
 * @property string $type          The type of one of the entities involved in the action
 * @property string $subtype       The subtype of one of the entities involved in the action
 * @property string $action_type   The name of the action
 * @property string $view          The view for displaying this river item
 * @property int    $access_id     The visibility of the river item
 * @property int    $posted        UNIX timestamp when the action occurred
 */
class ElggGolfCourseItem {
	public $golf_course_id;
	public $course_name;
	public $gold_course_rating;
	public $blue_course_rating;
	public $white_course_rating;
	public $red_white_course_rating;
	public $gold_course_slope;
	public $blue_course_slope;
	public $white_course_slope;
	public $red_course_slope;
	public $par_total;
	public $gold_total;
	public $blue_total;
	public $white_total;
	public $red_total;
	public $gold_tee_name;
	public $blue_tee_name;
	public $white_tee_name;
	public $red_tee_name;
	public $active_flg;

	/**
	 * Construct a river item object given a database row.
	 *
	 * @param stdClass $object Object obtained from database
	 */
	function __construct($object) {
		if (!($object instanceof stdClass)) {
			// throw exception
		}
		
		// the casting is to support typed serialization like json
		$int_types = array('golf_course_id', 
				'gold_course_slope', 'blue_course_slope', 'white_course_slope', 'red_course_slope', 
				'par_total', 'gold_total', 'blue_total', 'white_total', 'red_total', 
				'active_flg');
		$float_types = array(
				'gold_course_rating', 'blue_course_rating', 'white_course_rating', 'red_white_course_rating');
		foreach ($object as $key => $value) {
			if (in_array($key, $int_types)) {
				$this->$key = (int)$value;
			} else if (in_array($key, $float_types)) {
				$this->$key = (float)$value;
			} else {
				$this->$key = $value;
			}
		}
	}
	
	function getGolfCourseCard() {
		return elgg_get_golf_course_card(array('golf_course_id' => $this->golf_course_id));
	}
	
}
